<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php session_start();
$link = mysql_connect('cash2uca.ipagemysql.com', 'cash2uca', 'actW3740!@#$'); 
if (!$link) { 
    die('Could not connect: ' . mysql_error()); 
} 
mysql_select_db(cash2uca);

if(!isset($_SESSION['username'])||empty($_SESSION['username']))
{echo "If you are returning customer, please start your ". "<a href='member.php'>application here</a> now, thank you for your cooperation!";
exit();
}

$sqlEmail = "SELECT * FROM MainTable WHERE UserName = '$_POST[email]'";

$resultemail=mysql_query($sqlEmail);
$row = mysql_fetch_array($resultemail);
$RowEmail=mysql_num_rows($resultemail);
$PID=$row['ProfileID'];
$USERS=$row['username'];

if ($RowEmail!=0){
if($PID==$_SESSION['ProfileID']){}
else{
echo "<b style='color:black;'>"."Attention please:<b><br/><br/>";
echo "<p style='color:blue;'>Your updated email address is already in our system, please use another email address </a><p>";
exit();}
}

$sqlinsert1 = "UPDATE Profiles SET FirstName='$_POST[fName]',LastName='$_POST[lName]', Gender='$_POST[gender]', BirthDate='$_POST[birthdate]', Address='$_POST[address]', City='$_POST[city]', Province='$_POST[mprovince]', PostCode='$_POST[postcode]', DateIn='$_POST[datein]', PrimaryPhone='$_POST[primaryphone]', WorkPhone='$_POST[workphone]', CellPhone='$_POST[cellphone]', Email='$_POST[email]', Advertisement='$_POST[advertisement]', SIN='$_POST[SIN]', DriverLicense='$_POST[driver]', R1Name='$_POST[r1name]', R2Name='$_POST[r2name]', R1Phone='$_POST[r1phone]', R2Phone='$_POST[r2phone]', R1Relation='$_POST[r1relation]' WHERE ProfileID= '".$_SESSION['ProfileID']."'";

$resultin1=mysql_query($sqlinsert1);

$sqlinsert2 = "UPDATE MainTable SET UserName='$_POST[email]' WHERE ProfileID= '".$_SESSION['ProfileID']."'";

$resultin2=mysql_query($sqlinsert2);


//To send out email if session email is set up already
if (isset($_SESSION['username']))
    {//send email
    $email = $_SESSION['username'];
    $subject = "Profile updating";
    $message = "Hi, \n\n Your profile has been updated. Your username is ".$email. " Please remember to use your new email to login when you come back. \n\nThank you for choosing www.cash2u.ca!\n\nCash2u.ca appreciates your business!\n\n";
    $message=wordwrap($message,70);

    mail($email, $subject,$message,"From:customerservicessupport@cash2u.ca");
    }

//The above is to send out email to the applicant
$link = mysql_connect('cash2uca.ipagemysql.com', 'cash2uca', 'actW3740!@#$'); 
?>

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Cash2u.ca: Payday loan online application processing</title>
<META NAME="Keywords" CONTENT="payday loan, payday cash advance, online, payday advance, payday cash loan, payday loans, cash advance, paycheque loans, short term,
	money mart, money here, quick cash,check,cashing,easy,tax, bill,payment,currency,card,credit,Easy Cash Advances, Internet Payday loans, Payroll Advance, Payday Loan Services,
	Online Payday Advances, Online Payday Loan Provider, Pay Day, Canada">
<META NAME="Description" CONTENT=Cash2u.ca offers online payday loans and cash advance for Canadians">

<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js"></script>
<script src="./css/jquery.maskedinput.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="./css/main_style.css"/>
<link rel="stylesheet" type="text/css" href="./css/index.css"/>
</head>
<body onload="DoMath()">
<div id="maincontainer">

<div id="headsection">
<div id="headback">
<br/><br/><br/><h1><a style="color:white;" href="apply.php">Cash to you</a></h1><p id="headpara"><a style="color:white;" href="apply.php">Simple Easy Fast - Your payday loan</a></p>
</div>
</div>

<table cellspacing="4" cellpadding="1" border="0" style="margin:5px;height:50px;width:740px;background-color:#084c8d;border:1px solid #e5e5e5;color:white;font-size:110%;font-weight:bold;">
<tr><td width="20"></td>
<td width="90" align="center"><a class="headlink" href="index.html">HOME</a></td>
<td width="90" align="center"><a class="headlink" href="apply.php">APPLY</a></td>
<td width="130" align="center"><a class="headlink" href="member.php"><span class="displace">MEMBERS</span></a></td>
<td width="110" align="center"><a class="headlink" href="career.php"><span class="displace">CAREER</span></a></td>
<td width="90" align="center"><a class="headlink" href="faqs.php"><span class="displace">FAQ's</span></a></td>
<td width="90" align="center"><a class="headlink" href="contact.php"><span class="displace">CONTACT</span></a></td>
<td width="140"></td>
</tr>
</table>

<div id="content">

    	<form name="application" method="post" action="">
	<table>	
	<tr>
	<td width="740" align="left">Hi,</br></br>

Your profile has been updated successfully.</br></br>

Thank you for choosing <a href="www.cash2u.ca">www.cash2u.ca!</a></br></br>

Cash2u.ca appreciates your business.</br></br>

5 seconds later, this page will be redirected to: <a href="www.cash2u.ca">www.cash2u.ca</a>

		</td>
		</tr>

	</table>

	</form>

<div id="footer">
<div id="imlinks"><b><strong>Copyright &#169 2011 Cash2u.ca All rights reserved</strong></b></div>
</div>

</div>

<?php
header("refresh:5;url=http://www.cash2u.ca");
session_destroy();
?> 
</body>
</html>